package com.example.demo.entity.response.repository;

import com.example.demo.common.entity.response.BaseResponse;
import com.example.demo.entity.pojo.repository.PurchaseRepositoryPoJo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.springframework.beans.BeanUtils;

import java.util.Objects;

/**
 * 采购单入库响应对象
 *
 * @author Mei Ruoxiao
 * @date 2020-09-19
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@ApiModel("采购单入库响应对象")
@ToString(callSuper = true)
public class PurchaseRepositoryResponse extends BaseResponse {

    @ApiModelProperty(value = "名称", example = "芯片")
    private String name;
    @ApiModelProperty(value = "规格/型号", example = "HD20200915S")
    private String spec;
    @ApiModelProperty(value = "品牌", example = "鸿达安视")
    private String brand;
    @ApiModelProperty(value = "单位", example = "片")
    private String unit;
    @ApiModelProperty(value = "采购数量", example = "1562")
    private Integer quantity;
    @ApiModelProperty(value = "入库数量", example = "124")
    private Integer stock;
    @ApiModelProperty(value = "状态(是否完成入库) 0:未完成入库 1:完成入库", example = "1")
    private Integer state;

    public static PurchaseRepositoryResponse of(final PurchaseRepositoryPoJo poJo) {
        PurchaseRepositoryResponse response = new PurchaseRepositoryResponse();
        if (Objects.isNull(poJo)) {
            return response;
        }
        // 将 Domain 对象转换成 Response 对象
        BeanUtils.copyProperties(poJo, response);
        return response;
    }

}
